package sniff.pack;

public class MyTCPPacket extends CommonIPChildPacket {
	protected int sourctPort;
	protected int destinationPort;
	protected long seqNum;
	protected long ackNum;
	protected int dataMigration;
	protected String keep;
	protected int urg;
	protected int ack;
	protected int psh;
	protected int rst;
	protected int syn;
	protected int fin;
	protected int windowSize;
	protected String checkNum;
	protected String urgentPoint;
	protected String padding;
	protected CommonTCPChildPacket childPacket;
	
	public MyTCPPacket() {
		
	}
	
	public MyTCPPacket(int sourctPort, int destinationPort, long seqNum, long ackNum, int dataMigration, String keep,
			int urg, int ack, int psh, int rst, int syn, int fin, int windowSize, String checkNum, String urgentPoint,
			String padding) {
		this.sourctPort = sourctPort;
		this.destinationPort = destinationPort;
		this.seqNum = seqNum;
		this.ackNum = ackNum;
		this.dataMigration = dataMigration;
		this.keep = keep;
		this.urg = urg;
		this.ack = ack;
		this.psh = psh;
		this.rst = rst;
		this.syn = syn;
		this.fin = fin;
		this.windowSize = windowSize;
		this.checkNum = checkNum;
		this.urgentPoint = urgentPoint;
		this.padding = padding;
	}
	public int getSourctPort() {
		return sourctPort;
	}
	public void setSourctPort(int sourctPort) {
		this.sourctPort = sourctPort;
	}
	public int getDestinationPort() {
		return destinationPort;
	}
	public void setDestinationPort(int destinationPort) {
		this.destinationPort = destinationPort;
	}
	public long getSeqNum() {
		return seqNum;
	}
	public void setSeqNum(long seqNum) {
		this.seqNum = seqNum;
	}
	public long getAckNum() {
		return ackNum;
	}
	public void setAckNum(long ackNum) {
		this.ackNum = ackNum;
	}
	public int getDataMigration() {
		return dataMigration;
	}
	public void setDataMigration(int dataMigration) {
		this.dataMigration = dataMigration;
	}
	public String getKeep() {
		return keep;
	}
	public void setKeep(String keep) {
		this.keep = keep;
	}
	public int getUrg() {
		return urg;
	}
	public void setUrg(int urg) {
		this.urg = urg;
	}
	public int getAck() {
		return ack;
	}
	public void setAck(int ack) {
		this.ack = ack;
	}
	public int getPsh() {
		return psh;
	}
	public void setPsh(int psh) {
		this.psh = psh;
	}
	public int getRst() {
		return rst;
	}
	public void setRst(int rst) {
		this.rst = rst;
	}
	public int getSyn() {
		return syn;
	}
	public void setSyn(int syn) {
		this.syn = syn;
	}
	public int getFin() {
		return fin;
	}
	public void setFin(int fin) {
		this.fin = fin;
	}
	public int getWindowSize() {
		return windowSize;
	}
	public void setWindowSize(int windowSize) {
		this.windowSize = windowSize;
	}
	public String getCheckNum() {
		return checkNum;
	}
	public void setCheckNum(String checkNum) {
		this.checkNum = checkNum;
	}
	public String getUrgentPoint() {
		return urgentPoint;
	}
	public void setUrgentPoint(String urgentPoint) {
		this.urgentPoint = urgentPoint;
	}
	public String getPadding() {
		return padding;
	}
	public void setPadding(String padding) {
		this.padding = padding;
	}
	public CommonTCPChildPacket getChildPacket() {
		return childPacket;
	}

	public void setChildPacket(CommonTCPChildPacket childPacket) {
		this.childPacket = childPacket;
	}

	@Override
	public String getInfo() {
		if(childPacket!=null) {
			return this.childPacket.getInfo();
		}
		return super.getInfo();
	}

	@Override
	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append("Source Port:"+this.sourctPort+"\n");
		sb.append("Destination Port:"+this.destinationPort+"\n");
		sb.append("Sequence Number:"+this.seqNum+"\n");
		sb.append("Acknowledgment Number:"+this.ackNum+"\n");
		sb.append("DataMigration:"+this.dataMigration+"\n");
		sb.append("Keep:"+this.keep+"\n");
		sb.append("URG:"+this.urg+"\n");
		sb.append("ACK:"+this.ack+"\n");
		sb.append("PSH:"+this.psh+"\n");
		sb.append("RST:"+this.rst+"\n");
		sb.append("SYN:"+this.syn+"\n");
		sb.append("FIN:"+this.fin+"\n");
		sb.append("Window Size:"+this.windowSize+"\n");
		sb.append("Check Number:"+this.checkNum+"\n");
		sb.append("Urgent Point:"+this.urgentPoint+"\n");
		sb.append("[Options|Padding]:"+this.padding+"\n");
		if(this.childPacket!=null) {
			sb.append(this.childPacket.toString());
		}
		
		return sb.toString();
	}
}
